package com.archetype.schedule.config;

import com.cellulam.framework.datasource.ServiceDSAspect;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

import java.util.regex.Pattern;

/**
 *
 */
@Aspect
@Configuration
@Order(Ordered.HIGHEST_PRECEDENCE)
public class DsAspect extends ServiceDSAspect {

    public DsAspect() {
    }

    /**
     * for current project
     */
    @Pointcut("execution(* com.archetype.service.services..*.*(..))")
    public void servicePointcut() {

    }

    @Around("servicePointcut() || baseCrudPointcut() || baseDtoPointcut()")
    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
        return super.doAround(pjp);
    }

    @Override
    public Pattern getServicePackPattern() {
        return Pattern.compile("com\\.archetype\\.service\\.services\\.(.+?)\\.");
    }

}
